import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { LabelsService } from './labels.service';
import { CreateLabelDto } from './dto/create-label.dto';
import { UpdateLabelDto } from './dto/update-label.dto';
import { QueryDto } from './dto/query.dto';

@Controller()
export class LabelsController {
  constructor(private readonly labelsService: LabelsService) {}

  @MessagePattern('createLabel')
  create(@Payload() createLabelDto: CreateLabelDto) {
    return this.labelsService.create(createLabelDto);
  }

  @MessagePattern('findAllLabels')
  findAll(@Payload() queryDto: QueryDto) {
    return this.labelsService.findAll(queryDto);
  }

  @MessagePattern('findOneLabel')
  findOne(@Payload() id: number) {
    return this.labelsService.findOne(id);
  }

  @MessagePattern('updateLabel')
  update(@Payload('id') id: number,@Payload('updateLabelDto') updateLabelDto: UpdateLabelDto) {
    return this.labelsService.update(id, updateLabelDto);
  }

  @MessagePattern('removeLabel')
  remove(@Payload() id: number) {
    return this.labelsService.remove(id);
  }
}
